package com.example.demo.application;

import com.example.demo.HelloController;
import com.example.demo.UController;
import com.example.demo.model.UserInfo;
import com.example.demo.service.UserService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ComponentScan;

@ComponentScan(basePackages = "com.example.demo")
@SpringBootApplication
public class Springmvcdemo3Application {

	public static void main(String[] args) {
		ApplicationContext context = SpringApplication.run(Springmvcdemo3Application.class, args);
		HelloController bean = context.getBean(HelloController.class);
		bean.sayHi();

		HelloController bean1 = context.getBean("helloController",HelloController.class);
		bean1.sayHi();

		UController bean2 = (UController)context.getBean("UController");
		bean2.sayHi();

		UserService bean3 = context.getBean(UserService.class);
		bean3.doService();

		UserInfo bean4 = context.getBean(UserInfo.class);
		System.out.println(bean4);
	}
}
